package com.wiscamp.ninechapters.problems.infrastructure.mappers.exams;

import com.wiscamp.ninechapters.problems.infrastructure.po.exams.ExamTypeRelationView;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;

/**
 * 考试及题型关联数据访问对象
 *
 * @author yifeng
 */
@Repository
public interface ExamTypeRelationViewMapper extends JpaRepository<ExamTypeRelationView, Long>, JpaSpecificationExecutor<ExamTypeRelationView> {

    /**
     * 通过考试编号获取题型关联列表
     *
     * @param examId
     * @return
     */
    @Query(value = "select er from ExamTypeRelationView er where er.examId = :examId order by er.problemTypeId asc")
    Collection<ExamTypeRelationView> findByExam(long examId);


}